<include file="Public/head" />

<body>
  <form action="" id="listform">
    <div class="panel admin-panel">
      <div class="panel-head"><strong class="icon-reorder"> 体验者</strong></div>
      <div class="padding border-bottom">
        <ul class="search" style="padding-left:10px;">
          <li>绑定体验者：</li>
          <li><input class="input" type="text" name="wechatid" value="{$wechatid}" placeholder="请输入体验者微信号"></li>
          <li><input type="button" value="绑定" class="button border-main icon-search" onclick="return bdsub()"/></li>
        </ul>
      </div>
      <table class="table table-hover text-center">
        <tr>
          <th>微信号</th>
          <th>绑定时间</th>
          <th width="310">操作</th>
        </tr>
        <foreach name="info" item="v">
          <tr class="tr{$v['accradmin_id']}">
            <td>{$v['wechatid']|default="--"}</td>
            <td>{$v['addtime']|date="Y-m-d H:i:d",###}</td>
            <td>
              <div class="button-group">
                <a class="button border-red" href="javascript:void(0)" onclick="return del({$v['accradmin_id']})"><span class="icon-trash-o"></span> 解除绑定</a>
              </div>
            </td>
          </tr>
        </foreach>
      </table>
    </div>
  </form>
  <script type="text/javascript">
    function bdsub(){
    	var wechatid = $("input[name='wechatid']").val();
     	if(wechatid){
    		var url = "{:U('Accredit/adminer')}";
    		$.getJSON(url,{wechatid:wechatid},function (data){
        		if(data.result == 'ok'){alert('申请成功，请在该微信接受绑定邀请');location.reload();}
         		else{alert(data.result);}
        	})
      	}else{
      		alert('请输入需要绑定的微信号');
      	}
    }


    function del(id){
    	if(confirm("确认解除绑定吗？")){
        	var url = "{:U('Accredit/adminer_del')}";
        	$.getJSON(url,{id:id},function (data){
        		if(data.result == 'ok'){$(".tr"+id).remove();}
         		else{alert(data.result);}
        	})
      	}
    }
  </script>
</body>

</html>